using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.Position;

namespace TrainingManagement.api.Models.BusinessLogic.Position
{
    public class PositionCreateOperation : BusinessOperation<BusinessObjects.Position, BusinessObjects.Position>
    {
        readonly PositionInsertDataSource _positionInsert = new PositionInsertDataSource();

        public override BusinessObjects.Position Run(BusinessObjects.Position input)
        {
            if (_positionInsert.Execute(input))
            {
                return input;
            }
            throw new Exception(string.Format("{0} was not saved!", input.Title));
        }
    }
}